package com.digitalchina.lxnsy.activity.standard;

import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.RequiresApi;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.entity.MessageDetailVO;
import com.digitalchina.lxnsy.entity.MsgListVO;
import com.digitalchina.lxnsy.entity.OperationRecordsVO;
import com.digitalchina.lxnsy.entity.SchemaJsonVO;
import com.digitalchina.lxnsy.toolkit.FastJsonUtil;
import com.digitalchina.lxnsy.toolkit.JointImageUrl;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.digitalchina.lxnsy.toolkit.Utils;
import com.digitalchina.lxnsy.xml.AdminXML;
import com.lzy.ninegrid.ImageInfo;
import com.lzy.ninegrid.NineGridView;
import com.lzy.ninegrid.preview.NineGridViewClickAdapter;
import com.lzy.okhttputils.model.HttpParams;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.activity.standard
 * 创建人：郑皓
 * 创建时间：2019/7/11 19:00
 * 修改备注：
 * ================================================
 */
public class PlanFarmingRecordDetailsActivity extends BaseActivity {

    @Bind(R.id.view1)
    ImageView view1;
    @Bind(R.id.layout1)
    LinearLayout layout1;
    @Bind(R.id.tv_time)
    TextView tvTime;
    @Bind(R.id.tv_type)
    TextView tvType;
    @Bind(R.id.tv_weather)
    TextView tvWeather;
    @Bind(R.id.tv_variety)
    TextView tvVariety;
    @Bind(R.id.tv_whq)
    TextView tvWhq;
    @Bind(R.id.tv_land)
    TextView tvLand;
    @Bind(R.id.tv1a)
    TextView tv1a;
    @Bind(R.id.tv1b)
    TextView tv1b;
    @Bind(R.id.iv1)
    ImageView iv1;
    @Bind(R.id.layout_jichu)
    RelativeLayout layoutJichu;
    @Bind(R.id.tv_mu)
    TextView tvMu;
    @Bind(R.id.tv_work_time)
    TextView tvWorkTime;
    @Bind(R.id.tv_people_num)
    TextView tvPeopleNum;
    @Bind(R.id.tv_member)
    TextView tvMember;
    @Bind(R.id.layout_jichu_add)
    LinearLayout layoutJichuAdd;
    @Bind(R.id.tv2a)
    TextView tv2a;
    @Bind(R.id.tv2b)
    TextView tv2b;
    @Bind(R.id.iv2)
    ImageView iv2;
    @Bind(R.id.layout_nongyao)
    RelativeLayout layoutNongyao;
    @Bind(R.id.layout_nongyao_add)
    LinearLayout layoutNongyaoAdd;
    @Bind(R.id.layout_parent1)
    LinearLayout layoutParent1;
    @Bind(R.id.tv3a)
    TextView tv3a;
    @Bind(R.id.tv3b)
    TextView tv3b;
    @Bind(R.id.iv3)
    ImageView iv3;
    @Bind(R.id.layout_huafei)
    RelativeLayout layoutHuafei;
    @Bind(R.id.layout_huafei_add)
    LinearLayout layoutHuafeiAdd;
    @Bind(R.id.layout_parent2)
    LinearLayout layoutParent2;
    @Bind(R.id.tv4a)
    TextView tv4a;
    @Bind(R.id.tv4b)
    TextView tv4b;
    @Bind(R.id.iv4)
    ImageView iv4;
    @Bind(R.id.layout_dapeng)
    RelativeLayout layoutDapeng;
    @Bind(R.id.layout_dapeng_add)
    LinearLayout layoutDapengAdd;
    @Bind(R.id.layout_parent3)
    LinearLayout layoutParent3;
    @Bind(R.id.tv5a)
    TextView tv5a;
    @Bind(R.id.tv5b)
    TextView tv5b;
    @Bind(R.id.iv5)
    ImageView iv5;
    @Bind(R.id.layout_jixie)
    RelativeLayout layoutJixie;
    @Bind(R.id.layout_jixie_add)
    LinearLayout layoutJixieAdd;
    @Bind(R.id.layout_parent4)
    LinearLayout layoutParent4;
    @Bind(R.id.tv6a)
    TextView tv6a;
    @Bind(R.id.tv6b)
    TextView tv6b;
    @Bind(R.id.iv6)
    ImageView iv6;
    @Bind(R.id.layout_touru)
    RelativeLayout layoutTouru;
    @Bind(R.id.layout_touru_add)
    LinearLayout layoutTouruAdd;
    @Bind(R.id.layout_parent5)
    LinearLayout layoutParent5;
    @Bind(R.id.tv7a)
    TextView tv7a;
    @Bind(R.id.tv7b)
    TextView tv7b;
    @Bind(R.id.iv7)
    ImageView iv7;
    @Bind(R.id.layout_fangfa)
    RelativeLayout layoutFangfa;
    @Bind(R.id.layout_fangfa_add)
    LinearLayout layoutFangfaAdd;
    @Bind(R.id.layout_parent6)
    LinearLayout layoutParent6;
    @Bind(R.id.tv8a)
    TextView tv8a;
    @Bind(R.id.tv8b)
    TextView tv8b;
    @Bind(R.id.iv8)
    ImageView iv8;
    @Bind(R.id.layout_caishou)
    RelativeLayout layoutCaishou;
    @Bind(R.id.layout_caishou_add)
    LinearLayout layoutCaishouAdd;
    @Bind(R.id.layout_parent7)
    LinearLayout layoutParent7;
    @Bind(R.id.tv9a)
    TextView tv9a;
    @Bind(R.id.tv9b)
    TextView tv9b;
    @Bind(R.id.iv9)
    ImageView iv9;
    @Bind(R.id.layout_jiagong)
    RelativeLayout layoutJiagong;
    @Bind(R.id.layout_jiagong_add)
    LinearLayout layoutJiagongAdd;
    @Bind(R.id.layout_parent8)
    LinearLayout layoutParent8;
    @Bind(R.id.tv_msg_info)
    TextView tvMsgInfo;
    @Bind(R.id.nineGrid)
    NineGridView nineGridView;
    @Bind(R.id.tv_edit)
    TextView tvEdit;
    @Bind(R.id.tv_delete)
    TextView tvDelete;
    @Bind(R.id.layout2)
    LinearLayout layout2;
    @Bind(R.id.layout_tel)
    LinearLayout layoutTel;
    @Bind(R.id.tv10a)
    TextView tv10a;
    @Bind(R.id.tv10b)
    TextView tv10b;
    @Bind(R.id.iv10)
    ImageView iv10;
    @Bind(R.id.layout_dingzhi)
    RelativeLayout layoutDingzhi;
    @Bind(R.id.layout_dingzhi_add)
    LinearLayout layoutDingzhiAdd;
    @Bind(R.id.layout_parent9)
    LinearLayout layoutParent9;

    private MsgListVO vo;
    private String messageId = "";// msg ID
    private String tel = "";// 电话

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_plan_farming_record_details);
    }

    @Override
    public void initMember() {
        vo = (MsgListVO) getIntent().getSerializableExtra("MsgListVO");
        messageId = vo.getMessageId();

        setTitle(vo.getMessageName());

        getMsgDetail();
    }

    @Override
    public void addListener() {
        layoutTel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!StringUtil.isStrEmpty(tel))
                    Utils.callPhone(activity, tel);
                else
                    showToast("获取中，请稍候重试");
            }
        });
    }

    @Override
    public void setHandler() {
        mHandler = new Handler(new Handler.Callback() {
            @Override
            public boolean handleMessage(Message message) {
                switch (message.what) {
                    case MSG_S_0: // 详情
                        callBack(message.obj);
                        break;
                    case MSG_F_0:
                        showToast(message.obj.toString());
                        break;
                }
                return false;
            }
        });
    }

    @Override
    public void callBack(Object object) {
        MessageDetailVO msgVO = FastJsonUtil.getBean(object.toString(), "messageDetailVO", MessageDetailVO.class);

        if (msgVO != null) {
            setView(msgVO);
        }
    }

    private void setView(MessageDetailVO msgVO) {

        tel = msgVO.getMobilePhone();

        OperationRecordsVO data = msgVO.getOperationRecordsVO();
        if (data != null) {
            // 公共部分
            // 时间
            tvTime.setText(data.getOperationDate());
            // 天气
            tvWeather.setText("天气：" + data.getWeather() + " " + data.getWeatherDescribe());
            // 物候期
            tvWhq.setText(data.getPhaseName());
            // 补充说明
            if (StringUtil.isStrEmpty(data.getSpecification())) {
                tvMsgInfo.setVisibility(View.GONE);
            } else {
                tvMsgInfo.setVisibility(View.VISIBLE);
                tvMsgInfo.setText(data.getSpecification() + "");
            }

            //农事操作
            tvType.setText(data.getFarmOperationName());

            //品种
            tvVariety.setText("品种：" + data.getVarietyName());

            //地块
            if (StringUtil.isStrEmpty(data.getLandName())) {
                tvLand.setVisibility(View.GONE);
            } else {
                tvLand.setVisibility(View.VISIBLE);
                tvLand.setText("地块：" + data.getLandName());
            }


            //基础信息
            tvMu.setText(data.getMuNumber());
            tvWorkTime.setText(data.getHours());
            tvPeopleNum.setText(data.getPeopleNum());
            tvMember.setText(data.getMember());


            // 图片展示
            if (data.getFarmingOperationsimgs() != null && data.getFarmingOperationsimgs().size() > 0) {
                nineGridView.setVisibility(View.VISIBLE);
                ArrayList<ImageInfo> imageInfo = new ArrayList<>();

                for (int i = 0; i < data.getFarmingOperationsimgs().size(); i++) {
                    ImageInfo info = new ImageInfo();
                    info.setThumbnailUrl(JointImageUrl.smallImageUrl(data.getFarmingOperationsimgs().get(i).getImage()));
                    info.setBigImageUrl(JointImageUrl.bigImageUrl(data.getFarmingOperationsimgs().get(i).getImage()));
                    imageInfo.add(info);
                }
                nineGridView.setAdapter(new NineGridViewClickAdapter(activity, imageInfo));

            } else {
                nineGridView.setVisibility(View.GONE);
            }


            if (data.getAgriculturalOperationSchemeVO() != null) {
                //农药
                List<SchemaJsonVO> list1 = data.getAgriculturalOperationSchemeVO().getFertilizerSchemeList();
                if ((list1 != null && list1.size() > 0)) {
                    layoutNongyaoAdd.removeAllViews();
                    layoutParent1.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list1.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);

                        tvName.setText(list1.get(i).getName());
                        if ("YES".equals(list1.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("用量：" + list1.get(i).getUseNumber() + list1.get(i).getUnit());
                        tv12.setText("亩用量：" + list1.get(i).getMuNumber() + list1.get(i).getUnit());

                        layoutNongyaoAdd.addView(view);
                    }

                } else {
                    layoutParent1.setVisibility(View.GONE);
                }

                //化肥
                List<SchemaJsonVO> list2 = data.getAgriculturalOperationSchemeVO().getPesticideSchemeList();
                if ((list2 != null && list2.size() > 0)) {
                    layoutHuafeiAdd.removeAllViews();
                    layoutParent2.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list2.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);

                        tvName.setText(list2.get(i).getName());
                        if ("YES".equals(list2.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("用量：" + list2.get(i).getUseNumber() + "kg");
                        tv12.setText("亩用量：" + list2.get(i).getMuNumber() + "kg/亩");

                        layoutHuafeiAdd.addView(view);
                    }

                } else {
                    layoutParent2.setVisibility(View.GONE);
                }

                //大棚管理
                List<SchemaJsonVO> list3 = data.getAgriculturalOperationSchemeVO().getManageItemsRowsSchemeList();
                if ((list3 != null && list3.size() > 0)) {
                    layoutDapengAdd.removeAllViews();
                    layoutParent3.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list3.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);

                        tvName.setText(list3.get(i).getName());
                        if ("YES".equals(list3.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("行数：" + list3.get(i).getRowsNumber() + "行");
                        tv12.setText("株数：" + list3.get(i).getTreeNumber() + "株");

                        layoutDapengAdd.addView(view);
                    }

                } else {
                    layoutParent3.setVisibility(View.GONE);
                }

                //机械设备
                List<SchemaJsonVO> list4 = data.getAgriculturalOperationSchemeVO().getMachineryEquipmentSchemeList();
                if ((list4 != null && list4.size() > 0)) {
                    layoutJixieAdd.removeAllViews();
                    layoutParent4.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list4.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);

                        tvName.setText(list4.get(i).getName());
                        if ("YES".equals(list4.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("油耗：" + list4.get(i).getUseNumber() + "L");
                        tv12.setText("亩油耗：" + list4.get(i).getMuNumber() + "L/亩");

                        layoutJixieAdd.addView(view);
                    }

                } else {
                    layoutParent4.setVisibility(View.GONE);
                }

                //投入品
                List<SchemaJsonVO> list5 = data.getAgriculturalOperationSchemeVO().getInProductSchemeList();
                if ((list5 != null && list5.size() > 0)) {
                    layoutTouruAdd.removeAllViews();
                    layoutParent5.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list5.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);
                        View v2 = view.findViewById(R.id.v2);
                        LinearLayout layout2 = view.findViewById(R.id.layout2);
                        TextView tv21 = view.findViewById(R.id.tv_21);
                        TextView tv22 = view.findViewById(R.id.tv_22);


                        v2.setVisibility(View.VISIBLE);
                        layout2.setVisibility(View.VISIBLE);

                        tvName.setText(list5.get(i).getName());
                        if ("YES".equals(list5.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("地膜：" + list5.get(i).getFilmNumber() + "kg");
                        tv12.setText("亩用量：" + list5.get(i).getFilmMuNumber() + "kg");
                        tv21.setText("滴灌带用量：" + list5.get(i).getDripDosage() + "m");
                        tv22.setText("亩用量：" + list5.get(i).getDripMuDosage() + "m");

                        layoutTouruAdd.addView(view);
                    }

                } else {
                    layoutParent5.setVisibility(View.GONE);
                }

                //技术方法-定值
                List<SchemaJsonVO> list9 = data.getAgriculturalOperationSchemeVO().getColonizationSchemeList();
                if ((list9 != null && list9.size() > 0)) {
                    layoutDingzhiAdd.removeAllViews();
                    layoutParent9.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list9.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);


                        tvName.setText(list9.get(i).getName());
                        if ("YES".equals(list9.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("株数：" + list9.get(i).getUseNumber() + "个");
                        tv12.setText("亩株数：" + list9.get(i).getMuNumber() + "个/亩");

                        layoutDingzhiAdd.addView(view);
                    }

                } else {
                    layoutParent9.setVisibility(View.GONE);
                }


                //技术方法-育苗
                List<SchemaJsonVO> list6 = data.getAgriculturalOperationSchemeVO().getTechnicalMethodsSchemeList();
                if ((list6 != null && list6.size() > 0)) {
                    layoutFangfaAdd.removeAllViews();
                    layoutParent6.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list6.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);
                        View v2 = view.findViewById(R.id.v2);
                        LinearLayout layout2 = view.findViewById(R.id.layout2);
                        TextView tv21 = view.findViewById(R.id.tv_21);
                        TextView tv22 = view.findViewById(R.id.tv_22);
                        View v3 = view.findViewById(R.id.v3);
                        LinearLayout layout3 = view.findViewById(R.id.layout3);
                        TextView tv31 = view.findViewById(R.id.tv_31);
                        TextView tv32 = view.findViewById(R.id.tv_32);

                        v2.setVisibility(View.VISIBLE);
                        layout2.setVisibility(View.VISIBLE);
                        v3.setVisibility(View.VISIBLE);
                        layout3.setVisibility(View.VISIBLE);

                        tvName.setText(list6.get(i).getName());
                        if ("YES".equals(list6.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("育苗：" + list6.get(i).getSeedlingNumber() + "个");
                        tv12.setText("穴盘：" + list6.get(i).getAcupointPlate() + "个");
                        tv21.setText("基质：" + list6.get(i).getMatrixDosage() + "袋");
                        tv22.setText("浇水：" + list6.get(i).getWateringNumber() + "次");
                        tv31.setText("种子：" + list6.get(i).getBagNum() + "袋");

                        String time;
                        if (!StringUtil.isStrEmpty(list6.get(i).getEmergenceTime()) && list6.get(i).getEmergenceTime().length() > 10)
                            time = list6.get(i).getEmergenceTime().substring(0, 10);
                        else
                            time = "";
                        tv32.setText("出苗时间：" + time);

                        layoutFangfaAdd.addView(view);
                    }

                } else {
                    layoutParent6.setVisibility(View.GONE);
                }

                //采收
                List<SchemaJsonVO> list7 = data.getAgriculturalOperationSchemeVO().getHarvestPackagingSchemeList();
                if ((list7 != null && list7.size() > 0)) {
                    layoutCaishouAdd.removeAllViews();
                    layoutParent7.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list7.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);
                        View v2 = view.findViewById(R.id.v2);
                        LinearLayout layout2 = view.findViewById(R.id.layout2);
                        TextView tv21 = view.findViewById(R.id.tv_21);
                        TextView tv22 = view.findViewById(R.id.tv_22);

                        v2.setVisibility(View.VISIBLE);
                        layout2.setVisibility(View.VISIBLE);

                        tvName.setText(list7.get(i).getName());
                        if ("YES".equals(list7.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("采收重量：" + list7.get(i).getUseNumber() + "kg");
                        tv12.setText("亩采收重量：" + list7.get(i).getMuNumber() + "kg");
                        tv21.setText("包装规格：" + list7.get(i).getPackingSize());
                        tv22.setText("批次：" + list7.get(i).getBatch());

                        layoutCaishouAdd.addView(view);
                    }

                } else {
                    layoutParent7.setVisibility(View.GONE);
                }

                //加工
                List<SchemaJsonVO> list8 = data.getAgriculturalOperationSchemeVO().getProcessedPackagingSchemeList();
                if ((list8 != null && list8.size() > 0)) {
                    layoutJiagongAdd.removeAllViews();
                    layoutParent8.setVisibility(View.VISIBLE);

                    for (int i = 0; i < list8.size(); i++) {
                        View view = View.inflate(activity, R.layout.item_farming_add_v2, null);
                        TextView tvName = view.findViewById(R.id.tv_name);
                        TextView tvStandard = view.findViewById(R.id.tv_standard);
                        TextView tv11 = view.findViewById(R.id.tv_11);
                        TextView tv12 = view.findViewById(R.id.tv_12);
                        View v2 = view.findViewById(R.id.v2);
                        LinearLayout layout2 = view.findViewById(R.id.layout2);
                        TextView tv21 = view.findViewById(R.id.tv_21);
                        TextView tv22 = view.findViewById(R.id.tv_22);
                        View v3 = view.findViewById(R.id.v3);
                        LinearLayout layout3 = view.findViewById(R.id.layout3);
                        TextView tv31 = view.findViewById(R.id.tv_31);
                        TextView tv32 = view.findViewById(R.id.tv_32);
                        View v4 = view.findViewById(R.id.v4);
                        LinearLayout layout4 = view.findViewById(R.id.layout4);
                        TextView tv41 = view.findViewById(R.id.tv_41);
                        TextView tv42 = view.findViewById(R.id.tv_42);

                        v2.setVisibility(View.VISIBLE);
                        layout2.setVisibility(View.VISIBLE);
                        v3.setVisibility(View.VISIBLE);
                        layout3.setVisibility(View.VISIBLE);
                        v4.setVisibility(View.VISIBLE);
                        layout4.setVisibility(View.VISIBLE);


                        tvName.setText(list8.get(i).getName());
                        if ("YES".equals(list8.get(i).getIsStandardEnforcement())) {
                            tvStandard.setText("按标准执行");
                        } else {
                            tvStandard.setText("未按标准执行");
                        }

                        tv11.setText("加工件数：" + list8.get(i).getProcessedNumber() + "个");
                        tv12.setText("加工重量：" + list8.get(i).getProcessedWeight() + "kg");
                        tv21.setText("人均加工件数：" + list8.get(i).getAvgProcessedNumber() + "个");
                        tv22.setText("包装箱（袋）：" + list8.get(i).getBoxNumber() + "个");
                        tv31.setText("冰袋：" + list8.get(i).getIcpPack() + "个");
                        tv32.setText("包装绳：" + list8.get(i).getPackingRope() + "斤");
                        tv41.setText("包装材料费：" + list8.get(i).getPackagingMaterialsFee() + "元");
                        tv42.setText("冷库预冷费：" + list8.get(i).getColdStorageFee() + "元");

                        layoutJiagongAdd.addView(view);
                    }

                } else {
                    layoutParent8.setVisibility(View.GONE);
                }
            }


//        getPesticideSchemeList() != null && getPesticideSchemeList().size() > 0
//        getManageItemsRowsSchemeList() != null && getManageItemsRowsSchemeList().size() > 0
//        getMachineryEquipmentSchemeList() != null && getMachineryEquipmentSchemeList().size() > 0
//        getInProductSchemeList() != null && getInProductSchemeList().size() > 0
//        getTechnicalMethodsSchemeList() != null && getTechnicalMethodsSchemeList().size() > 0
//        getHarvestPackagingSchemeList() != null && getHarvestPackagingSchemeList().size() > 0
//        getProcessedPackagingSchemeList() != null && getProcessedPackagingSchemeList().size() > 0


            //基础信息layout
            layoutJichu.setOnClickListener(new View.OnClickListener() {
                @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
                @Override
                public void onClick(View view) {
                    if (layoutJichuAdd.getVisibility() == View.VISIBLE) {
                        layoutJichuAdd.setVisibility(View.GONE);
                        layoutJichu.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv1a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv1b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv1.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutJichuAdd.setVisibility(View.VISIBLE);
                        layoutJichu.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv1a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv1b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv1.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //农药
            layoutNongyao.setOnClickListener(new View.OnClickListener() {
                @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
                @Override
                public void onClick(View view) {
                    if (layoutNongyaoAdd.getVisibility() == View.VISIBLE) {
                        layoutNongyaoAdd.setVisibility(View.GONE);
                        layoutNongyao.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv2a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv2b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv2.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutNongyaoAdd.setVisibility(View.VISIBLE);
                        layoutNongyao.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv2a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv2b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv2.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //化肥
            layoutHuafei.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (layoutHuafeiAdd.getVisibility() == View.VISIBLE) {
                        layoutHuafeiAdd.setVisibility(View.GONE);
                        layoutHuafei.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv3a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv3b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv3.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutHuafeiAdd.setVisibility(View.VISIBLE);
                        layoutHuafei.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv3a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv3b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv3.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //大棚管理
            layoutDapeng.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (layoutDapengAdd.getVisibility() == View.VISIBLE) {
                        layoutDapengAdd.setVisibility(View.GONE);
                        layoutDapeng.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv4a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv4b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv4.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutDapengAdd.setVisibility(View.VISIBLE);
                        layoutDapeng.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv4a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv4b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv4.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //机械设备
            layoutJixie.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (layoutJixieAdd.getVisibility() == View.VISIBLE) {
                        layoutJixieAdd.setVisibility(View.GONE);
                        layoutJixie.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv5a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv5b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv5.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutJixieAdd.setVisibility(View.VISIBLE);
                        layoutJixie.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv5a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv5b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv5.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //投入品
            layoutTouru.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (layoutTouruAdd.getVisibility() == View.VISIBLE) {
                        layoutTouruAdd.setVisibility(View.GONE);
                        layoutTouru.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv6a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv6b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv6.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutTouruAdd.setVisibility(View.VISIBLE);
                        layoutTouru.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv6a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv6b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv6.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //技术方法-定值
            layoutDingzhi.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (layoutDingzhiAdd.getVisibility() == View.VISIBLE) {
                        layoutDingzhiAdd.setVisibility(View.GONE);
                        layoutDingzhi.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv10a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv10b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv10.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutDingzhiAdd.setVisibility(View.VISIBLE);
                        layoutDingzhi.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv10a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv10b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv10.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //技术方法-育苗
            layoutFangfa.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (layoutFangfaAdd.getVisibility() == View.VISIBLE) {
                        layoutFangfaAdd.setVisibility(View.GONE);
                        layoutFangfa.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv7a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv7b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv7.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutFangfaAdd.setVisibility(View.VISIBLE);
                        layoutFangfa.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv7a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv7b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv7.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //采收
            layoutCaishou.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (layoutCaishouAdd.getVisibility() == View.VISIBLE) {
                        layoutCaishouAdd.setVisibility(View.GONE);
                        layoutCaishou.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv8a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv8b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv8.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutCaishouAdd.setVisibility(View.VISIBLE);
                        layoutCaishou.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv8a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv8b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv8.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });

            //加工
            layoutJiagong.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (layoutJiagongAdd.getVisibility() == View.VISIBLE) {
                        layoutJiagongAdd.setVisibility(View.GONE);
                        layoutJiagong.setBackgroundColor(activity.getResources().getColor(R.color.colorFontLightGrayD));
                        tv9a.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        tv9b.setTextColor(activity.getResources().getColor(R.color.colorFontBlack));
                        iv9.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_shouqi));
                    } else {
                        layoutJiagongAdd.setVisibility(View.VISIBLE);
                        layoutJiagong.setBackgroundColor(activity.getResources().getColor(R.color.app_color));
                        tv9a.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        tv9b.setTextColor(activity.getResources().getColor(R.color.colorWhite));
                        iv9.setBackground(activity.getResources().getDrawable(R.drawable.ic_farming_zhankai));
                    }
                }
            });
        }

    }

    @Override
    public void rightOnClick() {

    }

    public void getMsgDetail() {

        /**
         * messageId	消息ID
         * userAccId	用户ID
         */
        HttpParams params = new HttpParams();
        params.put("enterpriseId", AdminXML.getEnterpriseId(activity));
        params.put("resNo", AdminXML.getResNo(activity));
        params.put("userAccId", AdminXML.getUserAccId(activity));
        params.put("messageId", messageId);

        OkHttpUtil.post(activity, URL.URL_GET_MESSAGE_DETAIL, "正在加载", params, mHandler,
                MSG_S_0, MSG_F_0);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
